package main.mvc;

import java.lang.reflect.Field;

import com.spring.annotation.entity.NotPersistent;
import com.spring.bean.example.Book;

public class BuildColumns {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(getColumnStr(Book.class));
	}
	
	public static <T> String getColumnStr(Class cls){
		Field[] fields = cls.getDeclaredFields();
		StringBuffer columStr = new StringBuffer();
		for(int i=0; i<fields.length; i++){
			if(fields[i].isAnnotationPresent(NotPersistent.class)){
				continue;
			}
			columStr.append(fields[i].getName() + ",");
		}
		return columStr.substring(0, columStr.length()-1).toString();
	}

}
